//
//  LoginComfirmViewCell.m
//  OfficeBook
//
//  Created by 朱 琳 on 15/10/11.
//  Copyright (c) 2015年 sunny. All rights reserved.
//

#import "LoginComfirmViewCell.h"

@interface LoginComfirmViewCell()

@property (nonatomic, strong) UIButton *confirm;
@property (nonatomic, strong) UILabel *otherLogin;

@end

@implementation LoginComfirmViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    
    self.confirm = [[UIButton alloc]init];
    [self.confirm setTitle:@"登 录" forState:UIControlStateNormal];
    [self.confirm setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    self.confirm.backgroundColor = [UIColor yellowColor];
    [self.confirm.layer setCornerRadius:4];
    self.otherLogin = [[UILabel alloc]init];
    self.otherLogin.text = @"还可以选择以下登入方式";
    [self.contentView addSubview:self.confirm];
    [self.contentView addSubview:self.otherLogin];
    
    [self.confirm makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView.top).offset(20);
        make.centerX.equalTo(self.contentView.centerX);
        make.width.equalTo(self.contentView).multipliedBy(0.9);
        make.height.equalTo(@44);
    }];
    
    self.otherLogin.textAlignment = NSTextAlignmentLeft;
    [self.otherLogin makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.confirm).offset(120);
        make.left.equalTo(self.contentView).offset(10);
        make.width.equalTo(self.contentView);
        make.height.equalTo(@40);
    }];
    
    [self.confirm addTarget:self action:@selector(doConfirm) forControlEvents:UIControlEventTouchUpInside];
    
    return self;
}
- (void)drawRect:(CGRect)rect {
    CGContextRef context = UIGraphicsGetCurrentContext();
    
    CGContextSetFillColorWithColor(context, [UIColor whiteColor].CGColor);
    CGContextFillRect(context, rect);
    
    CGContextSetStrokeColorWithColor(context, [UIColor colorWithRed:0xE2/255.0f green:0xE2/255.0f blue:0xE2/255.0f alpha:1].CGColor);
    CGContextStrokeRect(context, CGRectMake(10, rect.size.height, rect.size.width - 20, 0.8));
}

- (void)doConfirm {
    NSLog(@"confirm!!");
    [self.delegate doLogin];
}

@end
